import { ref, computed } from "vue";
import { defineStore } from "pinia";
interface IState {
  // 用户信息
  menuList: any[];
  // // 权限列表
  // purview: string[];
}
export const useMenuRecordStore = defineStore("menuRecord", {
  state: () => ({
    menuList:[] as any,
  }),
  getters: {
    // 获得菜单列表
    //   menuList(): RouteRecordRaw[] {
    //     const routes: RouteRecordRaw[] = router.getRoutes().filter(item => item.meta.isMenu && hasPurview([item.meta.mark as string]));
    //     return routeTree(routes, "");
    //   }
    getMeunList ()  {
      let list:any = localStorage.getItem('menuRecord')
      let lists = JSON.parse(list) 
      console.log('getMeunList',lists);
      this.menuList = lists.menuList;

    },
  },
  actions: {
    addMenu(val: object) {
      this.menuList.push(val);
    },
    delMenu(path: string) {
      let index = this.menuList.indexOf(path)
      if (index > -1) {
        this.menuList.splice(index,1);
      }
      
    },
  },
  persist: true,
});
